package cn.cubix.flow.config;

import cn.hutool.core.lang.generator.SnowflakeGenerator;
import lombok.RequiredArgsConstructor;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * 为解决flowable图片中的中文乱码
 */
@Configuration
@RequiredArgsConstructor(onConstructor=@__({@Autowired,@Lazy}))
public class CusFlowableConfig implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {

    private final SnowflakeGenerator snowflakeGenerator;

    @Override
    public void configure(SpringProcessEngineConfiguration engineConfiguration) {
        engineConfiguration.setActivityFontName("宋体");
        engineConfiguration.setLabelFontName("宋体");
        engineConfiguration.setAnnotationFontName("宋体");
        engineConfiguration.setIdGenerator(()->String.valueOf(snowflakeGenerator.next()));
    }
}
